<template>
  <div>
    <!-- 顶部智慧商城导航  -->
    <div class="nav_bar">
    智慧商城
    </div>
    <!-- 搜索 -->
    <div class="search">
      <input type="text" placeholder="请输入你要找的商品" @click="$router.push('/searchIndex')">
    </div>
    <!-- 轮播 -->
    <van-swipe class="my-swipe" :autoplay="1500" indicator-color="white">
      <van-swipe-item v-for="item in bannerList" :key="item.imgUrl">
        <img :src="item.imgUrl">
      </van-swipe-item>
    </van-swipe>
    <!-- 通知栏 -->
    <van-notice-bar
      color="white"
      background="gray"
      left-icon="volume-o"
      font-size="30px"
      text="智慧商城2.0全新上线，更多新品等你来选~。    智慧商城2.0全新上线，更多新品等你来选~。"
    />
    <!-- 宫格 -->
    <van-grid :column-num="5" class="gongge">
      <van-grid-item v-for="item in navList" :key="item.imgUrl">
        <img :src="item.imgUrl">
        <h6>{{ item.text }}</h6>
      </van-grid-item>
    </van-grid>
    <!-- 主会场 -->
    <div class="main">
      <img src="@/assets/main.png">
    </div>
    <!-- 猜你喜欢 -->
    <div class="you_like">
      <div>
        <span>猜你喜欢</span>
      </div>
    </div>
    <goods-item-base v-for="item in goodsList" :key="item.goods_id" :goodsMessage="item"></goods-item-base>
    <p style="text-align: center">已经到底了</p>
    <br><br><br>
  </div>
</template>

<script>
import GoodsItemBase from '@/components/GoodsItemBase.vue'
import { getHome } from '@/api/Home.js'
export default {
  name: 'HomeIndex',
  data () {
    return {
      bannerList: [], // 轮播图片
      navList: [], // 导航图片(宫格)
      goodsList: [] // 商品组(猜你喜欢)
    }
  },
  async created () {
    const { data: { pageData: { items } } } = await getHome()
    this.bannerList = items[1].data
    this.navList = items[3].data
    this.goodsList = items[6].data
    // console.log(items[6].data)
  },
  components: {
    GoodsItemBase
  }
}
</script>

<style scoped>
/* 顶部智慧商城导航 */
.nav_bar {
  width:100%;
  height:40px;
  background:red;
  color:white;
  text-align:center;
  line-height:40px;
  position:fixed;
  top:0;
  left:0;
}
/* 搜索 */
.search {
  padding:10px;
  margin-top:40px;
  background:lightblue;
}
.search input {
  width:100%;
  height:30px;
  border-radius:50px;
  padding-left:30px;
}
/* 轮播 */
.my-swipe .van-swipe-item {
    color: #fff;
    font-size: 20px;
    height: 200px;
    text-align: center;
    background-color: #39a9ed;
  }
.my-swipe img {
  width:100%;
  height:100%;
}
/* 宫格 */
.gongge img {
  width:50px;
  height:50px;
}
/* 主会场 */
.main img {
  width:100%;
}
/* 猜你喜欢 */
.you_like {
  display:flex;
  height:45px;
  justify-content:center;
  align-items:flex-start;
  border-bottom:2px solid rgb(100, 90, 90, 0.3);
}
.you_like div {
  width:150px;
  text-align:center;
  border-bottom:1px solid black;
}
.you_like div span {
  position:relative;
  bottom:-10px;
  background:white;
}
</style>
